;--------------------------------------
;
; vdAttr.asm
;
; vdAttr(row,col,len,string,attr)
;
; Byte row     row of string write
; Byte col     column of string write
; Byte len     number of bytes to write
; char *string  pointer to string to write
; Byte attr    attribute of screen write
;
;--------------------------------------
;
; include defs, prototypes and macros
;

include tab6.inc

;--------------------------------------
;
; begin code segment
;

    .Code

vdAttr PROC Pascal PUBLIC USES es di ds si bx, row:Byte,
                                               col:Byte,
                                               len:WORD,
                                               attr:Byte

; es gets screen segment

IF mdl eq 3
    push   ds
    mov    ax,SEG scrn_seg
    mov    ds,ax
    mov    ax,ds:scrn_seg
    mov    es,ax
    pop    ds
ELSE
    mov    ax,scrn_seg
    mov    es,ax
 ENDIF
    sub    ax,ax         ; 0 -> ax
    mov    al,row        ; row -> al
    mov    bl,160        ; 160 = (80 chars wide * 2)
    mul    bl            ; row * scrn width  -> ax
    mov    cl,col        ; column to cl
    sub    ch,ch         ; 0 -> ch
    shl    cx,1          ; col * 2
    add    ax,cx         ; column + (row * scrn width)
    mov    di,ax         ; point di to scrn
    cld                  ; direction increment
    mov    al,attr       ; load atttribute byte
    mov    cx,len        ; string len -> cx
    .REPEAT
    inc     di           ; bypass char byte
    stosb                ; attribute to screen
    dec    cx
    .UNTIL (cx==0)
    ret
vdAttr ENDP

    END

;
;--------------------------------------    
    

